package com.studio701.carguard.controller;


import com.studio701.carguard.pojo.HelpQuestion;
import com.studio701.carguard.service.IHelpQuestionService;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xjc
 * @since 2022-03-16
 */
@RestController
@RequestMapping("/help-question")
public class HelpQuestionController {

    @Autowired
    private IHelpQuestionService iHelpQuestionService;

    @GetMapping("/")
    public List<HelpQuestion> getAllquestions(){
        return iHelpQuestionService.getQuestionWithAnswer();
    }

    @ApiOperation("筛选主题问答")
    @GetMapping("/{qTheme}")
    public List<HelpQuestion> getQuestionsByWithAnswerQTheme(@PathVariable("qTheme") String theme){
        return iHelpQuestionService.getQuestionsWithAnswerByQTheme(theme);
    }

    @ApiOperation("添加问答")
    @PostMapping("/")
    public boolean insertQuestion(@RequestBody HelpQuestion helpQuestion){
        return iHelpQuestionService.save(helpQuestion);
    }


}
